$(document).ready(function () {
    /*咨询电话、微信*/
    $.ajax({
        url:inbterfaceConsulting,
        type:'post',
        success:function (data) {
            // console.log(data);
            if(data.success){
                $(".Consulting-phone").eq(0).html("咨询电话："+data.page.phone);
                $(".Consulting-WeChat").eq(0).html("咨询微信："+data.page.weixin);
            }
        }
    })

    // var documentHeight=document.body.scrollHeight;
    // console.log("docH"+documentHeight);
    // var clientHeight=document.body.clientHeight;
    // console.log("cliH"+clientHeight);
    // if(clientHeight<600){
    //     $(".footer").css("position","static");
    //     $(".footer").css("margin-top","90px");
    // }else{
    //     $(".footer").css("position","absolute");
    //     $(".footer").css("bottom","0px");
    // }
    //
    // /*屏幕翻转时,保证底部信息样式不遮盖按钮*/
    // $(window).on("orientationchange",function(even){
    //     if(even.orientation=="landscape"){    //竖屏:portrait,横屏:landscape
    //         $(".footer").css("position","static");
    //         $(".footer").css("margin-top","90px");
    //     } else {
    //         if(clientHeight<600){
    //             $(".footer").css("position","static");
    //             $(".footer").css("margin-top","90px");
    //         }else{
    //             $(".footer").css("position","absolute");
    //             $(".footer").css("bottom","0px");
    //         }
    //     }
    // });
    //*页头部右边图标点击，判断是否登录，登录跳转个人中心，未登录跳转登录页*/
    $("#personSpan").off("tap").on("tap",function () {
        $.ajax({
            url:interfaceGetState+generateMixed(9),
            type:'post',
            success:function (data) {
                if(data.status==0){
                    window.location.href="/f/campusinfo/person"+generateMixed(9);
                }else {
                    alert("请先登录");
                    if(window.sessionStorage){
                        sessionStorage.setItem("prePage","/f/campusinfo/person");
                    }
                   window.location.href="/f/campusinfo/login"+generateMixed(9);
                }
            },
            error:function () {
                alert("error");
            }
        });

        return false;
    });

    /*只能填写正整数*/
    $(document).delegate(".positive-integer","input propertychange",function () {
        var contain=$(this).val();
        contain=contain.replace(/\D/g,'');
        var reg = /^[0]\d*$/;
        if(reg.test(contain)){
            contain=contain.substring(1,contain.length);
        }
        $(this).val(contain);
    });
    /*只能填非负数*/
    $(".nonnegative").bind("input propertychange",function () {
        var contain=$(this).val();
        contain=contain.replace(/[^\d.]/g,"");
        //只允许一个小数点
        var num = contain.split('.');
        // console.log(num.length);
        if(num.length>1){
            if(num[0]!=''){
                contain=num[0]+"."+num[1];
            }else {
                contain="0"+"."+num[1];
            }
        }else{
            contain=num[0];
        }
        $(this).val(contain);
    });

    /*不含空格,强制删除空格*/
    $(document).delegate(".no-space","input propertychange",function () {
        var contain=$(this).val();
        contain=contain.replace(/\s/g,'');
        $(this).val(contain);
    });

    /*数字、字母*/
    $(document).delegate(".d-a","input propertychange",function () {
            var contain=$(this).val();
            contain=contain.replace(/[^\w]/ig,'');
            $(this).val(contain);
    });

    /*非双字节*/
    $(document).delegate(".doubleByte","input propertychange",function () {
        var contain=$(this).val();
        contain=contain.replace(/[^\x00-\xff]/g,'');
        $(this).val(contain);
    })

    /*a标签，href的url添加随机数*/
    for(var i=0;i<$("a").length;i++){
        var url=$("a").eq(i).attr("href");
        if(url!=''&&url!='#'&&url!='##'){
            $("a").eq(i).attr("href",url+generateMixed(6));
        }
    }
})
/*是否实名*/
function realName(){
    $.ajax({
        url:interfaceRealName+generateMixed(9),
        type:'post',
        async:false,
        success:function(data){
            // console.log(data.status);
            if(data.status==0){ //已实名
               real=true;
            }else{      //未实名
                $(".header").prepend("<span><a  href=\"/f/campusinfo/personMsg"+generateMixed(9)+"\" data-transition=\"slideup\" data-ajax=\"false\"><span>去实名</span></a></span>");
               real=false;
            }
        }
    })
}
/*支付*/
/*弹窗*/
window.alert = function(name){
    var iframe = document.createElement("IFRAME");
    iframe.style.display="none";
    iframe.setAttribute("src", 'data:text/plain,');
    document.documentElement.appendChild(iframe);
    window.frames[0].window.alert(name);
    iframe.parentNode.removeChild(iframe);
}
/*随机数，url后添加，防止缓存*/
var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
function generateMixed(n) {
    var res = "?";
    for(var i = 0; i < n ; i ++) {
        var id = Math.ceil(Math.random()*35);
        res += chars[id];
    }
    return res;
}


